//
//  FBInputContentHandle.m
//  UILbrary
//
//  Created by Apple on 2023/3/4.
//  Copyright © 2023 mac. All rights reserved.
//

#import "FBInputContentHandle.h"
#import "HSFInputFieldView.h"

@interface FBInputContentHandle()

@property(nonatomic, strong) HSFInputFieldView *p_view;

@end

@implementation FBInputContentHandle

//MARK: - private

- (void)showTextNil
{
    [UIViewController showAelrtWithTitle:@"请先输入意见反馈"];
}

- (void)showParamError
{
    [UIViewController showAelrtWithTitle:@"参数错误，请开发自查"];
    assert(NO);
}

- (NSDictionary *)netRequestParam:(NSObject *)obj
{
    NSDictionary *tmp_dic = (NSDictionary *)obj;
    if(!tmp_dic){
        tmp_dic = @{};
    }
    NSMutableDictionary *mutableDic = [tmp_dic mutableCopy];
    [mutableDic addEntriesFromDictionary:tmp_dic];
    mutableDic[@"content"] = self.p_view.text;
    
    return [mutableDic copy];
}

//MARK: - FBCompleteProtocol

- (void)completeHandle:(NSObject *)obj
{
    if(!self.p_view.text || self.p_view.text.length <= 0){
        [self showTextNil];
        return;
    }
    [self.nextStep completeHandle:[self netRequestParam:obj]];
}

//MARK: - get

- (HSFInputFieldView *)p_view
{
    if(!_p_view){
        _p_view = [HSFInputFieldView new];
        _p_view.backgroundColor = [UIColor whiteColor];
        _p_view.placeholder = @"为了更好的帮助您解决问题，请在提交问题的同时上传截图信息，方便我们更快速的帮助您解决问题。另外您想要什么功能就在这里描述下吧!";
        _p_view.placeholderColor = [UIColor JX_GrayColor_5];
        _p_view.countColor = [UIColor JX_GrayColor_5];
        _p_view.maxInputLenth = 500;
        [_p_view clearInputText];
    }
    return _p_view;
}

- (UIView *)view
{
    return self.p_view;
}

@end
